using System;
using System.Collections.Generic;
using System.Text;

namespace tKitchen
{
    public class RecipeCategoryPresenter
    {
        tKitchenMain domain;
        RecipeCategoryInput inputForm;

        public RecipeCategoryPresenter(tKitchenMain domainIn)
        {
            domain = domainIn;
            inputForm = new RecipeCategoryInput(this);

            PopulateGrid();
           
        }

        internal void AddCategory(string nameIn, string descrIn)
        {
            RecipeCategory temp = new RecipeCategory();
            temp.Name = nameIn;
            temp.Descr = descrIn;

            domain.AddObject(temp);

            PopulateGrid();

        }

        internal void UpdateCategory(RecipeCategory temp)
        {
            domain.UpdateObject(temp);
            inputForm.RefreshGrid();
        }


        private void PopulateGrid()
        {
            List<RecipeCategory> list = domain.GetRecipeCategoryList();
            inputForm.SetDataSource(list);
            inputForm.RefreshGrid();
        }

        public void ShowForm()
        {
            inputForm.Show();
        }

    }
}
